import { EventKey } from '../common/Key';
cc.Class({
    extends: require('BaseUI'),

    properties: {
        nodMask: cc.Node,
        nodCore: cc.Node,
    },

    _onClose(isAction = true) {
        if (!isAction) {
            G.ui.closeUI(this.node);
            return;
        }
        let action = cc.sequence(
            cc.scaleTo(0.1, 1.02, 1.02),
            cc.scaleTo(0.1, 0, 0),
            cc.callFunc(()=>{
                G.ui.closeUI(this.node);
            })
        )
        this.nodCore.runAction(action);
    },

    onEnter(args, isAction) {
        this.enterArgs = args;
        this.nodMask.on('touchstart', this._onTouchStart, this);
        if (isAction) {
            let action = cc.sequence(
                cc.scaleTo(0.1, 1.02, 1.02),
                cc.scaleTo(0.1, 1, 1)
            )
            this.nodCore.runAction(action);
        }

        G.onFire.fire(EventKey.EVENT_ENTER_PANEL);
    },

    onExit(args) {
        this.nodMask.off('touchstart', this._onTouchStart, this);
        G.onFire.fire(EventKey.EVENT_EXIT_PANEL);
    },
    _onTouchStart(isAction = true) {
        this._onClose(isAction);
    },
});